﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Windows;

namespace Tierless.Framework.Utilities
{
	/// <summary>
	/// Provides utility methods for dealing with assemblies in the Tierless framework.
	/// </summary>
	public static class AssemblyUtility
	{
		/// <summary>
		/// Gest the list of assemblies loaded in the current app domain.
		/// </summary>
		/// <returns>An array of <see cref="Assembly"/> instances representing the currently loaded assemblies.</returns>
		public static Assembly[] GetAssemblies()
		{
			#if !SILVERLIGHT
			return AppDomain.CurrentDomain.GetAssemblies();
			#else
			return 
			(
				from LPart in Deployment.Current.Parts
					select new AssemblyPart().Load(Application.GetResourceStream(new Uri(LPart.Source, UriKind.Relative)).Stream)
			).ToArray();
			#endif
		}
	}
}
